var express = require('express');
var axios = require('axios');
var router = express.Router();
var aaa = new Array();

router.get('/', function (req, res, next) {
    let {test_number} = req.query
    // res.send("考试解析页面");
    var config = {
        method: 'get',
        baseURL: 'http://localhost:9023',
        url: '/student_work/getTestAnalysis',
        params: {
            studentId: req.session.userId,
            testNumber: test_number
        },
    }
    axios(config)
        .then(function (response) {
            aaa.push(response.data.data);
            aaa.push(response.data.otherData);
            console.log(response.data);
            if (response.data.code == 0) {
                console.log("获取试卷解析信息成功");
                res.render('webPage/analysis', {
                    list: aaa
                });
            } else {
                res.render('webPage/notFound');
                // res.send({ err: -1, msg: "获取试卷解析信息失败" })
                console.log("获取试卷解析信息失败")
            }
        })
        .catch(function (error) {
            // console.log(error);
           alert("服务器错误，请刷新页面")
            res.render('webPage/notFound');
            console.log("服务器错误")
            Window.onload;
        });
})

module.exports = router;
